﻿using System;
using ERTesting.Model.Config;
using ERTesting.Model.Result;
using GalaSoft.MvvmLight;

namespace ERTesting.Gui.ViewModel.Config
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class TestOutputViewModel : ViewModelBase
    {
        public TestOutput Output { get; private set; }

        #region Public Properties

        /// <summary>
        /// The <see cref="Range" /> property's name.
        /// </summary>
        public const string RangePropertyName = "Range";

        /// <summary>
        /// Gets the Range property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string Range
        {
            get
            {
                return Output.Range;
            }
        }

        /// <summary>
        /// The <see cref="ExpectedValue" /> property's name.
        /// </summary>
        public const string ExpectedValuePropertyName = "ExpectedValue";

        /// <summary>
        /// Gets the ExpectedValue property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string ExpectedValue
        {
            get
            {
                return Output.ExpectedValue;
            }

            set
            {
                if (Output.ExpectedValue == value)
                {
                    return;
                }

                Output.ExpectedValue = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(ExpectedValuePropertyName);
            }
        }

        /// <summary>
        /// The <see cref="ActualValue" /> property's name.
        /// </summary>
        public const string ActualValuePropertyName = "ActualValue";

        /// <summary>
        /// Gets the ActualValue property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string ActualValue
        {
            get
            {
                return Output.ActualValue;
            }
        }

        /// <summary>
        /// The <see cref="SignOff" /> property's name.
        /// </summary>
        public const string SignOffPropertyName = "SignOff";

        
        /// <summary>
        /// Gets the SignOff property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public SignOffEnum SignOff
        {
            get
            {
                return Output.SignOff;
            }

            set
            {
                if (Output.SignOff == value)
                {
                    return;
                }

                var oldValue = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(SignOffPropertyName);
            }
        }

        #endregion Public Properties

        #region Contructors

        /// <summary>
        /// Initializes a new instance of the TestOutputViewModel class.
        /// </summary>
        public TestOutputViewModel(TestOutput output)
        {
            Output = output;
        }

        #endregion Contructors

    }
}